package xml;


import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class XMLReaderI implements XMLReader {
    @Override
    public String getXmlString(String XMLPath) {
        SAXReader saxReader=new SAXReader();
        try {
            Document document= saxReader.read(XMLReaderI.class.getClassLoader().getResource(XMLPath));

            Element element1 = (Element) document.selectSingleNode("/Data/SettingSheet/ToolList/ToolInList/Tool/ToolId");
            String info1 = element1.getText();
            System.out.println("刀具ID:"+info1);

            Element element2 = (Element) document.selectSingleNode("/Data/SettingSheet/ToolList/ToolInList/Tool/Adapter/Name");
            String info2 = element2.getText();
            System.out.println("刀具名称:"+info2);

//            Element element3 = (Element) document.selectSingleNode("/Data/SettingSheet/ToolList/ToolInList/Tool/Step/MeasureStartTime");
//            String info3 = element3.getText();
//            System.out.println("测量开始时间:"+info3);
//
//            Element element4= (Element) document.selectSingleNode("/Data/SettingSheet/ToolList/ToolInList/Tool/Step/MeasureEndTime");
//            String info4 = element4.getText();
//            System.out.println("测量结束时间:"+info4);

            Element element5= (Element) document.selectSingleNode("/Data/SettingSheet/ToolList/ToolInList/Tool/Step/ZNominal");
            String info5 = element5.getText();
            System.out.println("刀纵向长度:" + info5);

            Element element6= (Element) document.selectSingleNode("/Data/SettingSheet/ToolList/ToolInList/Tool/Step/XNominal");
            String info6 = element6.getText();
            System.out.println("刀水平长度:" + info6);

//            Element element7= (Element) document.selectSingleNode("/Data/SettingSheet/ToolList/ToolInList/Tool/Step/Angle1Actual");
//            String info7 = element7.getText();
//            System.out.println("刀角:" + info7);
        } catch (DocumentException e) {
            e.printStackTrace();
        }
        return null;
    }
}
